// pages/xinzengdizhi/xinzengdizhi.js
const request = require("../../utils/request.js");
Page({
  /**
   * 页面的初始数据
   */
  data: {
    name: "",
    mobile: "",
    address: "",
    area: "",
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {},
  // 新增地址
  adddizhiList(total_score1, total_score2, area, total_score4) {
    console.log(total_score1, total_score2, area, total_score4);
    const _this = this;
    request.wxRequest(
      "address/add",
      function (err, data) {
        // console.log(data.data.list)
        if (err) {
          // 失败；
          console.error(err);
        } else {
          // 成功；
          console.log(data.data.list);
        }
      },
      "POST",
      {
        user_id: 1,
        name: total_score1,
        mobile: total_score2,
        area: area,
        address: total_score4,
      }
    );
  },
  addStart: function (a) {
    var myEvent = a.detail.son;
    console.log(myEvent);
    this.setData({
      area: myEvent,
    });
  },
  back_houtai: function (e) {
    var that = this;
    var area = that.data.area;
    //姓名
    var total_score1 = e.detail.value.total_score1;
    //手机号
    var total_score2 = e.detail.value.total_score2;
    //地址
    var area = e.detail.value.area;
    var total_score4 = e.detail.value.total_score4;
    console.log("姓名：" + total_score1);
    console.log("手机号:" + total_score2);
    console.log("地址:" + total_score4);
    console.log(area);
    // 新增地址
    this.adddizhiList(total_score1, total_score2, area, total_score4);
    wx.navigateTo({
      url: "/pages/mogome/mogo",
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {},
});
